package com.alibaba.dubbo.demo.consumer;

import java.util.HashMap;
import java.util.Map;
import com.alibaba.dubbo.rpc.service.GenericService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author zhangsulei
 *
 */
public class Consumer8 {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"});
        context.start();
        GenericService demoService = (GenericService) context.getBean("demoService8"); // get remote service proxy

    	// 如果是基本类型、以及Date、List、Map等不需要转换，直接调用，如果返回值是pojo，也将自动转换为map
    	// pojo参数要转换为map
    	Map<String, Object> st = new HashMap<>();
    	st.put("class", "com.alibaba.dubbo.demo.Student");
    	st.put("name", "zsl");
    	st.put("age", 10);
    	Object st2 = demoService.$invoke("sayHello", new String[]{"com.alibaba.dubbo.demo.Student"}, new Object[]{st});
    	System.out.println(st2);
    }
}
